﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.graphics {
    import flash.display.*;

    public class Graphics2D {

        protected var target:Graphics;
        private var brush:IBrush;

        public function Graphics2D(_arg1:Graphics){
            this.target = _arg1;
        }
        protected function setTarget(_arg1:Graphics):void{
            this.target = _arg1;
        }
        protected function dispose():void{
            this.target = null;
        }
        private function startPen(_arg1:IPen):void{
            _arg1.setTo(this.target);
        }
        private function endPen():void{
            this.target.lineStyle();
            this.target.moveTo(0, 0);
        }
        private function startBrush(_arg1:IBrush):void{
            this.brush = _arg1;
            _arg1.beginFill(this.target);
        }
        private function endBrush():void{
            this.brush.endFill(this.target);
            this.target.moveTo(0, 0);
        }
        public function clear():void{
            if (this.target != null){
                this.target.clear();
            };
        }
        public function drawLine(_arg1:IPen, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
            this.startPen(_arg1);
            this.line(_arg2, _arg3, _arg4, _arg5);
            this.endPen();
        }
        public function drawPolyline(_arg1:IPen, _arg2:Array):void{
            this.startPen(_arg1);
            this.polyline(_arg2);
            this.endPen();
        }
        public function fillPolyline(_arg1:IBrush, _arg2:Array):void{
            this.startBrush(_arg1);
            this.polyline(_arg2);
            this.endBrush();
        }
        public function drawPolygon(_arg1:Pen, _arg2:Array):void{
            this.startPen(_arg1);
            this.polygon(_arg2);
            this.endPen();
        }
        public function fillPolygon(_arg1:IBrush, _arg2:Array):void{
            this.startBrush(_arg1);
            this.polygon(_arg2);
            this.endBrush();
        }
        public function fillPolygonRing(_arg1:IBrush, _arg2:Array, _arg3:Array):void{
            this.startBrush(_arg1);
            this.polygon(_arg2);
            this.polygon(_arg3);
            this.endBrush();
        }
        public function drawRectangle(_arg1:IPen, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
            this.startPen(_arg1);
            this.rectangle(_arg2, _arg3, _arg4, _arg5);
            this.endPen();
        }
        public function fillRectangle(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
            this.startBrush(_arg1);
            this.rectangle(_arg2, _arg3, _arg4, _arg5);
            this.endBrush();
        }
        public function fillRectangleRing(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):void{
            this.startBrush(_arg1);
            this.rectangle((_arg2 - (_arg4 / 2)), (_arg3 - (_arg5 / 2)), _arg4, _arg5);
            this.rectangle((_arg2 - (_arg6 / 2)), (_arg3 - (_arg7 / 2)), _arg6, _arg7);
            this.endBrush();
        }
        public function fillRectangleRingWithThickness(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
            this.startBrush(_arg1);
            this.rectangle(_arg2, _arg3, _arg4, _arg5);
            this.rectangle((_arg2 + _arg6), (_arg3 + _arg6), (_arg4 - (_arg6 * 2)), (_arg5 - (_arg6 * 2)));
            this.endBrush();
        }
        public function drawCircle(_arg1:IPen, _arg2:Number, _arg3:Number, _arg4:Number):void{
            this.startPen(_arg1);
            this.circle(_arg2, _arg3, _arg4);
            this.endPen();
        }
        public function fillCircle(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number):void{
            this.startBrush(_arg1);
            this.circle(_arg2, _arg3, _arg4);
            this.endBrush();
        }
        public function fillCircleRing(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
            this.startBrush(_arg1);
            this.circle(_arg2, _arg3, _arg4);
            this.circle(_arg2, _arg3, _arg5);
            this.endBrush();
        }
        public function fillCircleRingWithThickness(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
            this.startBrush(_arg1);
            this.circle(_arg2, _arg3, _arg4);
            _arg4 = (_arg4 - _arg5);
            this.circle(_arg2, _arg3, _arg4);
            this.endBrush();
        }
        public function drawEllipse(_arg1:IPen, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
            this.startPen(_arg1);
            this.ellipse(_arg2, _arg3, _arg4, _arg5);
            this.endPen();
        }
        public function fillEllipse(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
            this.startBrush(_arg1);
            this.ellipse(_arg2, _arg3, _arg4, _arg5);
            this.endBrush();
        }
        public function fillEllipseRing(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):void{
            this.startBrush(_arg1);
            this.ellipse((_arg2 - (_arg4 / 2)), (_arg3 - (_arg5 / 2)), _arg4, _arg5);
            this.ellipse((_arg2 - (_arg6 / 2)), (_arg3 - (_arg7 / 2)), _arg6, _arg7);
            this.endBrush();
        }
        public function fillEllipseRingWithThickness(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
            this.startBrush(_arg1);
            this.ellipse(_arg2, _arg3, _arg4, _arg5);
            this.ellipse((_arg2 + _arg6), (_arg3 + _arg6), (_arg4 - (_arg6 * 2)), (_arg5 - (_arg6 * 2)));
            this.endBrush();
        }
        public function drawRoundRect(_arg1:IPen, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number=-1, _arg8:Number=-1, _arg9:Number=-1):void{
            this.startPen(_arg1);
            this.roundRect(_arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9);
            this.endPen();
        }
        public function fillRoundRect(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number=-1, _arg8:Number=-1, _arg9:Number=-1):void{
            this.startBrush(_arg1);
            this.roundRect(_arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9);
            this.endBrush();
        }
        public function fillRoundRectRing(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number, _arg9:Number):void{
            this.startBrush(_arg1);
            this.roundRect((_arg2 - (_arg4 / 2)), (_arg3 - (_arg5 / 2)), _arg4, _arg5, _arg6);
            this.roundRect((_arg2 - (_arg7 / 2)), (_arg3 - (_arg8 / 2)), _arg7, _arg8, _arg9);
            this.endBrush();
        }
        public function fillRoundRectRingWithThickness(_arg1:IBrush, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number=-1):void{
            this.startBrush(_arg1);
            this.roundRect(_arg2, _arg3, _arg4, _arg5, _arg6);
            if (_arg8 == -1){
                _arg8 = (_arg6 - _arg7);
            };
            this.roundRect((_arg2 + _arg7), (_arg3 + _arg7), (_arg4 - (_arg7 * 2)), (_arg5 - (_arg7 * 2)), _arg8);
            this.endBrush();
        }
        public function beginFill(_arg1:IBrush):void{
            this.startBrush(_arg1);
        }
        public function endFill():void{
            this.endBrush();
            this.target.moveTo(0, 0);
        }
        public function beginDraw(_arg1:IPen):void{
            this.startPen(_arg1);
        }
        public function endDraw():void{
            this.endPen();
            this.target.moveTo(0, 0);
        }
        public function moveTo(_arg1:Number, _arg2:Number):void{
            this.target.moveTo(_arg1, _arg2);
        }
        public function curveTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
            this.target.curveTo(_arg1, _arg2, _arg3, _arg4);
        }
        public function lineTo(_arg1:Number, _arg2:Number):void{
            this.target.lineTo(_arg1, _arg2);
        }
        public function line(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
            this.target.moveTo(_arg1, _arg2);
            this.target.lineTo(_arg3, _arg4);
        }
        public function polygon(_arg1:Array):void{
            if (_arg1.length > 1){
                this.polyline(_arg1);
                this.target.lineTo(_arg1[0].x, _arg1[0].y);
            };
        }
        public function polyline(_arg1:Array):void{
            var _local2:Number;
            if (_arg1.length > 1){
                this.target.moveTo(_arg1[0].x, _arg1[0].y);
                _local2 = 1;
                while (_local2 < _arg1.length) {
                    this.target.lineTo(_arg1[_local2].x, _arg1[_local2].y);
                    _local2++;
                };
            };
        }
        public function rectangle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
            this.target.drawRect(_arg1, _arg2, _arg3, _arg4);
        }
        public function ellipse(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
            this.target.drawEllipse(_arg1, _arg2, _arg3, _arg4);
        }
        public function circle(_arg1:Number, _arg2:Number, _arg3:Number):void{
            this.target.drawCircle(_arg1, _arg2, _arg3);
        }
        public function roundRect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number=-1, _arg7:Number=-1, _arg8:Number=-1):void{
            if (_arg6 == -1){
                _arg6 = _arg5;
            };
            if (_arg7 == -1){
                _arg7 = _arg5;
            };
            if (_arg8 == -1){
                _arg8 = _arg5;
            };
            this.target.drawRoundRectComplex(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
        }
        public function wedge(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
            var _local8:Number;
            var _local9:Number;
            var _local10:Number;
            var _local11:Number;
            this.target.moveTo(0, 0);
            this.target.lineTo(_arg1, 0);
            var _local5:Number = Math.floor((_arg4 / 30));
            var _local6:Number = (_arg4 - (_local5 * 30));
            var _local7:Number = 0.268;
            var _local12:Number = 0;
            var _local13:Number = 0;
            while (_local13 < _local5) {
                _local8 = (_arg1 * Math.cos((((_local13 + 1) * 30) * (Math.PI / 180))));
                _local9 = (_arg1 * Math.sin((((_local13 + 1) * 30) * (Math.PI / 180))));
                _local10 = (_local8 + ((_arg1 * _local7) * Math.cos(((((_local13 + 1) * 30) - 90) * (Math.PI / 180)))));
                _local11 = (_local9 + ((_arg1 * _local7) * Math.sin(((((_local13 + 1) * 30) - 90) * (Math.PI / 180)))));
                this.target.curveTo(_local10, _local11, _local8, _local9);
                _local12 = (_local13 + 1);
                _local13++;
            };
            if (_local6 > 0){
                _local7 = Math.tan(((_local6 / 2) * (Math.PI / 180)));
                _local8 = (_arg1 * Math.cos((((_local12 * 30) + _local6) * (Math.PI / 180))));
                _local9 = (_arg1 * Math.sin((((_local12 * 30) + _local6) * (Math.PI / 180))));
                _local10 = (_local8 + ((_arg1 * _local7) * Math.cos(((((_local12 * 30) + _local6) - 90) * (Math.PI / 180)))));
                _local11 = (_local9 + ((_arg1 * _local7) * Math.sin(((((_local12 * 30) + _local6) - 90) * (Math.PI / 180)))));
                this.target.curveTo(_local10, _local11, _local8, _local9);
            };
            this.target.lineTo(0, 0);
        }

    }
}//package org.aswing.graphics 
